package com.poetry.controller;

import com.poetry.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @GetMapping("/{id}")
    public String profile(@PathVariable Long id, Model model) {
        model.addAttribute("user", userService.findById(id));
        model.addAttribute("poems", userService.findPoemsByUserId(id));
        model.addAttribute("likedPoems", userService.findLikedPoemsByUserId(id));
        model.addAttribute("bookmarkedPoems", userService.findBookmarkedPoemsByUserId(id));
        return "user/profile";
    }
    
    @GetMapping("/settings")
    public String settings(Model model) {
        model.addAttribute("title", "登录界面");
        return "user/settings";
    }
} 